package com.gcq.javawork.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gcq.javawork.model.domain.ShoppingCart;
import com.gcq.javawork.service.ShoppingCartService;
import com.gcq.javawork.mapper.ShoppingCartMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

/**
* @author guochuqu
* @description 针对表【shopping_cart(购物车表)】的数据库操作Service实现
* @createDate 2024-10-16 16:40:05
*/
@Service
public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, ShoppingCart>
    implements ShoppingCartService{


    @Resource
    private ShoppingCartMapper shoppingCartMapper;

    @Override
    public List<ShoppingCart> getShoppingCartByUserId(Long userId) {
        List<ShoppingCart> shoppingCarts = shoppingCartMapper.selectToId(userId);

        return shoppingCarts;
    }

    @Override
    public void addGoodsTOCart(ShoppingCart shoppingCart) {
        if (shoppingCart == null)return;

        save(shoppingCart);

    }

    @Override
    public void deleteGoodsFromCart(ShoppingCart shoppingCart) {

        deleteGoodsFromCart(shoppingCart);
    }
}




